using System;
using System.Collections.Generic;
using System.Xml;
using System.Data;
using System.Diagnostics;
using Adoor.Expression;
using Adoor.Object;
using Adoor.Object.Entity;
using Adoor.Relational;
using Adoor.Data;  // For SmartKey

namespace Adoor.Object.Relational
{
    // TODO: temp class. parameterize AutoIncrementFactory in the XML
    [Obsolete("use AutoIncrementFactory instead")]
    public class AutoDecrementKeyFactory<TEntity> : AutoIncrementKeyFactory<TEntity>
    {
        public AutoDecrementKeyFactory(Adoor.Object.Domain.EntityData entityData, XmlNode metadata)
            : base(entityData, metadata)
        {
            Debug.Assert(false, "use AutoIncrementFactory instead");
            IEntityFactory factory = (IEntityFactory)this.EntityData.GetService(typeof(IEntityFactory));
            Adoor.Object.Relational.EntityTableFactory<TEntity> tableFactory = factory as Adoor.Object.Relational.EntityTableFactory<TEntity>;
#if Oracle
			this.sqlStatement = "select MIN(To_Number(" + this.PrimaryKey + ")) from " + tableFactory.TableName;
#else
            this.sqlStatement = "select MIN(" + this.PrimaryKey + ") from " + tableFactory.TableName;
#endif
            this.increment = -1;
        }
    }

	
}
